<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./lib/vue.js"></script>
    <style>
        li{
            border: 1px dashed #999;
            margin: 5px;
            line-height: 35px;
            padding-left: 5px;
            font-size: 12px;
            width: 100%;
        }
        .v-enter,
        .v-leave-to{
            opacity: 0;
            transform: translateY(90px)
        }
        .v-leave-active,
        .v-enter-active{
            transition: all 0.6s ease;
             
        }

        li:hover{
            background-color: blue;
            transition: 0.5s
        }

        /*下面的.v-move和.v-leave-active配合使用，能够实现列表后续的元素渐渐的漂上来的效果*/
        .v-move{
            transition: all 0.6s ease;
        }
        .v-leave-active{
            position: absolute
        }
    </style>
</head>
<body>
    <div id="app">
        <div>
            <label>
            ID:
            <input type="text" v-model="id">
            </label>
            
            <label>
            Name:
            <input type="text" v-model="name">
            </label>
            <input type="button" value="Add" @click="add">
        </div>
    
            <!--在实现列表过度的时候，如果需要过渡的元素是用transitionGroup 而不是 transition-->
            <!--给transition-group添加apper属性，实现入场时侯的效果-->
            <!--通过给transition-group标签tag属性指定将来transition-group渲染成什么元素-->
            <transition-group appear tag="ul">
            <!--如果要为v-for创建的元素设置动画，必须为每一个元素设置 :key属性-->
            <li v-for="(item, i) in list" :key="item.id" @click="del(i)">
                {{item.id}} ------------ {{item.name}}
            </li>     
            </transition-group>
    </div>
    <script>
        var vm = new Vue({    
            el: '#app',
            data:{
                id:'',
                name:'', 
                list:[
                {id:1, name:'Bob'},
                {id:2, name:'Trump'},
                {id:3, name:'Rechial'},
                {id:4, name:'Frank'}
                
                ]
            },
            methods: {
             add(){
                this.list.push({id:this.id, name:this.name})
                this.name=''
                this.id=''
             },
             del(i){
                 this.list.splice(i,1 )
             }    
            }, 
        })
    </script>
</body>
</html>